﻿@{
    ViewBag.Title = "UpLoad";
}
<link href="/Scripts/Uploadify/uploadify.css" rel="stylesheet" />
<script src="/Scripts/Uploadify/swfobject.js"></script>
<script src="/Scripts/Uploadify/jquery.uploadify.min.js"></script>
<div>
    <div class="inputDiv fl">
        <input type="text" name="ImagePath" id="ImagePath" style="width: 600px;">
        <img style="display: none;" />
    </div>
    <div class="fl" style="position: relative;">
        <input id="custom_file_uploadEdu" type="file" class="btn" />
        <a href="javascript:$('#custom_file_uploadEdu').uploadifyUpload()">上传</a>| 
      <a href="javascript:$('#custom_file_uploadEdu').uploadifyClearQueue()">取消上传</a>
    </div>
    <div id="displayMsg"></div>
</div>
<script type="text/ecmascript">

    $("#custom_file_uploadEdu").uploadify({
        'uploader': '/Scripts/Uploadify/uploadify.swf',
        'script': '/ashx/UploadFile.ashx',
        'cancelImg': '/Scripts/Uploadify/uploadify-cancel.png',
        'folder': '/',
        'queueSizeLimit': 1,
        'simUploadLimit': 1,
        'sizeLimit ': 1024 * 1024 * 500,/*大小限制500兆*/
        'successTimeout': 3600,/*上传成功之前的超时(单位:秒)*/
        'multi': false,/*多文件模式*/
        'auto': false,/*如果是自动上传,那上传按钮将没用了*/
        'fileExt': '*.jpg;*.gif;*.jpeg;*.mp4;*.flv;*.avi',
        'fileDesc': '请选择图像或者视频',
        'queueID': 'fileQueue',
        'width': 110,
        'height': 30,
        'buttonText': '选择',
        'wmode': 'opaque',
        'hideButton': false,
        'onSelect': function (event, ID, fileObj) {
            $("#displayMsg").html("等待上传......");
        },
        'onProgress': function (event, queueId, fileObj, data) {
            $("#displayMsg").html("上传中...进度:" + data.percentage + "%" + ",已经上传:" + data.allBytesLoaded + "/" + fileObj.size + ",上传速度:" + data.speed + "kb/s");
        },
        'onComplete': function (event, queueId, fileObj, response, data) {
            var ary = response.split('|');
            if (ary[0] == "0") { //提示错误信息
                alert(ary[1]);
            }
            else {
                if (ary[0] == "1") {//上传后的URL
                    $("#displayMsg").html("上传成功");
                    $("#ImagePath").attr("value", ary[1]); 
                    $("#ImagePath").next("img").show().attr({ "style": "width:50px;height:50px;", "src": ary[1] });
                } else {//异常信息
                    alert(ary[1]);
                }
            }
        }
    });
</script>
